<template>
  <div class="tabs">
    <div
      class="item"
      v-for="item in tabs"
      :key="item.id"
      :class="{ check: activeTab === item.id }"
      @click="emits('changeTab', item)"
    >
      <span>{{ item.title }}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
defineProps(["activeTab", "tabs"]);
const emits = defineEmits(["changeTab"]);
</script>

<style scoped lang="scss">
.tabs {
  margin: 0.3rem 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  box-sizing: border-box;
  gap: 1.3rem;
}
.tabs .item span {
  position: relative;
  z-index: 2;
}
.tabs .check {
  background: transparent;
}
.tabs .item {
  width: 50%;
  height: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.35rem;
  font-weight: 800;
  color: #dfb2c8;
  position: relative;
}
.tabs .check {
  color: #fff;
}
.tabs .item span {
  position: relative;
  z-index: 2;
}
.tabs .check span:before {
  content: "";
  width: 0.6rem;
  height: 0.1rem;
  background: #fff;
  border-radius: 0.2rem;
  position: absolute;
  bottom: -0.3rem;
  left: 50%;
  transform: translate(-50%);
}
</style>
